using System;
using System.Data;
using System.Collections.Generic;
namespace eTMS.DAO{
	/********************************BEGIN NewsDAO****************************************/
	///<summary>
	/// <para>Author: Auto generated class by CSharp Code Generator v2.0</para>
	/// <para>Date:28/09/2010 49:02:47</para>
	/// <para>Class Name: NewsDAO</para>
	/// <para>Description: Class access to table News in database. Class for coder code here</para>
	///</summary>

	
	public  class NewsDAO : NewsDAOBase{
        public DataSet SelectAllDSWithCateByCate_ID(int Cate_ID)
        {
            IDbCommand cmd = this.CreateCommand();
            List<string> lsFilter = new List<string>();
            cmd.CommandText = @"SELECT     News.MainContent, News.DatePost, News.Title,News.SmallImageUrl,News.LargeImageUrl, News.New_ID, Categories.CategoryName, Categories.Category_ID
                                    FROM       News INNER JOIN
                                           Categories ON News.Category_ID = Categories.Category_ID ";
            if (Cate_ID > 0)
            {                
                lsFilter.Add("Categories.Category_ID = " + Cate_ID.ToString());
            }
            else
            {

                lsFilter.Add("News.IsHomePage=1");
                lsFilter.Add("Categories.IsHomePage=1");
                lsFilter.Add("News.DateExprired>getdate()");
            }
            lsFilter.Add("News.Display=1");
            lsFilter.Add("Categories.Display=1");
            cmd.CommandText += " WHERE "+string.Join(" AND ",lsFilter.ToArray());
            return this.SelectDS(cmd);
        }

	}
	/*****************************************************************************************************/
	/**********************************END NewsDAO*****************************************/
	/*****************************************************************************************************/
}

